package cn.stylefeng.guns.modular.school.controller;

import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.modular.school.entity.ParkingPlaceUseInfo;
import cn.stylefeng.guns.modular.school.model.params.ParkingPlaceUseInfoParam;
import cn.stylefeng.guns.modular.school.service.ParkingPlaceUseInfoService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * 停车位使用情况信息控制器
 *
 * @author
 * @Date 2020-04-15 17:38:40
 */
@Controller
@RequestMapping("/parkingPlaceUseInfo")
public class ParkingPlaceUseInfoController extends BaseController {

    private String PREFIX = "/school/parkingPlaceUseInfo";

    @Autowired
    private ParkingPlaceUseInfoService parkingPlaceUseInfoService;

    /**
     * 跳转到主页面
     *
     * @author
     * @Date 2020-04-15
     */
    @RequestMapping("")
    public String index(String flag) {
        // all 车位使用信息 yuyue 预约信息
        setAttr("flag", flag);
        if (StringUtils.equals(flag, "all")) {
            return PREFIX + "/parkingPlaceUseInfo_all.html";
        }
        return PREFIX + "/parkingPlaceUseInfo.html";
    }

    /**
     * 新增页面
     *
     * @author
     * @Date 2020-04-15
     */
    @RequestMapping("/add")
    public String add() {
        return PREFIX + "/parkingPlaceUseInfo_add.html";
    }

    /**
     * 编辑页面
     *
     * @author
     * @Date 2020-04-15
     */
    @RequestMapping("/edit")
    public String edit() {
        return PREFIX + "/parkingPlaceUseInfo_edit.html";
    }

    /**
     * 新增接口
     *
     * @author
     * @Date 2020-04-15
     */
    @RequestMapping("/addItem")
    @ResponseBody
    public ResponseData addItem(ParkingPlaceUseInfoParam parkingPlaceUseInfoParam) {
        this.parkingPlaceUseInfoService.add(parkingPlaceUseInfoParam);
        return ResponseData.success();
    }

    /**
     * 编辑接口
     *
     * @author
     * @Date 2020-04-15
     */
    @RequestMapping("/editItem")
    @ResponseBody
    public ResponseData editItem(ParkingPlaceUseInfoParam parkingPlaceUseInfoParam) {
        this.parkingPlaceUseInfoService.update(parkingPlaceUseInfoParam);
        return ResponseData.success();
    }

    /**
     * 删除接口
     *
     * @author
     * @Date 2020-04-15
     */
    @RequestMapping("/delete")
    @ResponseBody
    public ResponseData delete(ParkingPlaceUseInfoParam parkingPlaceUseInfoParam) {
        this.parkingPlaceUseInfoService.delete(parkingPlaceUseInfoParam);
        return ResponseData.success();
    }

    /**
     * 查看详情接口
     *
     * @author
     * @Date 2020-04-15
     */
    @RequestMapping("/detail")
    @ResponseBody
    public ResponseData detail(ParkingPlaceUseInfoParam parkingPlaceUseInfoParam) {
        ParkingPlaceUseInfo detail = this.parkingPlaceUseInfoService.getById(parkingPlaceUseInfoParam.getId());
        return ResponseData.success(detail);
    }

    /**
     * 查询列表
     *
     * @author
     * @Date 2020-04-15
     */
    @ResponseBody
    @RequestMapping("/list")
    public LayuiPageInfo list(ParkingPlaceUseInfoParam parkingPlaceUseInfoParam) {
        return this.parkingPlaceUseInfoService.findPageBySpec(parkingPlaceUseInfoParam);
    }

}


